Introduction to Machine Learning

Unit 01: Course Overview

1. Introduction

Welcome to Introduction to Machine Learning . This unit provides an overview of the main concepts and topics that we will study in this course. We begin by defining machine learning and understanding how it differs from traditional rule-based problem solving. We then look at the major types of machine learning problems, including supervised and unsupervised learning. The unit also introduces the distinction between classification and regression, the curse of dimensionality, and the main steps involved in a machine learning project. These concepts provide the foundation for the algorithms and techniques covered in the later units.

2. Theory

2.1 What is Machine Learning?

There are several definitions of machine learning, but two well-known definitions are given by Arthur Samuel and Tom Mitchell:

"Machine learning is the field of study that gives computers the ability to learn without being explicitly programmed." — Arthur Samuel (1959)
"A computer program is said to learn from experience E with respect to some class of tasks T and performance measures P, if its performance at tasks in T, as measured by P, improves with experience E." — Tom Mitchell (1988)

Together, these definitions highlight an important idea: a machine learning system improves its performance by learning from experience or data rather than relying only on rules explicitly written by a programmer.

Example: Email Spam Detection (Click to expand)
  • Task (T): Deciding if an email is spam or not
  • Experience (E): Looking at thousands of emails labeled "spam" or "not spam"
  • Performance (P): Accuracy — how often the classifier gets the right answer

2.2 How Humans vs. Machines Make Decisions

Humans make decisions in two primary ways:

Supervised machine learning is closer to this second approach. Instead of manually writing rules for every possible situation, we provide the system with previous examples and allow it to learn a model from those examples. We can think of this process in three simple stages: Remember — Formulate — Predict framework:

Learning process diagram A three-step process showing Remember, Formulate, and Predict, with supporting descriptions beneath each step. Remember Access what is already known Formulate Create a model or rule Predict Apply learning to the future Look at previous data Build a model/rule from data Use model on NEW unseen data

2.3 Three Major Types of Machine Learning

Machine learning problems are commonly divided into three major paradigms: supervised learning, unsupervised learning, and reinforcement learning. The main difference between them is how the learning system receives information and feedback.

Supervised
Unsupervised
Reinforcement

2.4 Supervised Learning: Classification vs. Regression

Once we focus on supervised learning, another important distinction is needed. Supervised learning problems can be divided into classification and regression based on the type of output that the model needs to predict.

Aspect Classification Regression
Output Type Discrete / Categorical (classes) Continuous / Numerical (values)
Example Outputs Yes/No, Cat/Dog/Bird, Disease/Healthy $245,000, 72.3 °F, 3.8 GPA
Mathematical Goal Find decision boundary Minimize prediction error \( \sum (y - \hat{y})^2 \)

Side-by-Side Problem Examples

Classification Regression
Will it rain tomorrow? (Yes/No)How much rain will fall? (2.3 inches)
Is this email spam? (Spam/Ham)What's the spam probability? (0.73)
Which genre is this movie? (Action/Comedy/Drama)What rating will this movie get? (7.2/10)
Will customer buy? (Buy/Not Buy)How much will customer spend? ($127.50)

2.5 The Curse of Dimensionality

Machine learning datasets can contain a large number of features. When the number of features becomes very large, we face what is known as the curse of dimensionality . The high-dimensional data (hundreds or thousands of features) creates two critical problems:

  1. Computational challenge: Processing time grows exponentially with dimension count
  2. Performance degradation: Data becomes sparse in high-dimensional spaces, making it harder for models to generalize

One way to address these problems is dimensionality reduction . The basic idea is to keep the most useful information while reducing unnecessary or redundant features. This can also make the data easier to visualize, process, and analyze. Throughout this course, we will explore various dimensionality reduction techniques, including Principal Component Analysis (PCA) and feature selection methods.

2.6 Machine Learning Project Lifecycle

Learning individual machine learning algorithms is only one part of building a machine learning system. In practice, a machine learning project involves several steps, starting from collecting the raw data and ending with deploying and monitoring the final model. These steps are connected. Decisions made during data preparation affect model development, and mistakes made early in the process can lead to misleading evaluation results. For this reason, it is important to follow a proper workflow rather than treating model training as an isolated step. Every real-world ML project follows a structured 9-step lifecycle. Skipping or misordering steps is a common source of project failure.

Step 1: Raw Data Collection
Gathering data from various sources—databases, APIs, sensors, user interactions, etc. This raw data may come in different formats and may require integration from multiple sources.

Step 2: Initial Dataset Creation (Rows × Columns)
Organizing the collected data into a structured format where each row represents an example (instance) and each column represents a feature (attribute). At this stage, we have the basic dataset but haven't processed it further.

Step 3: Preprocessing Pipeline 1 – Data Cleaning (Performed on the Full Dataset)
Before we split the data, we fix universal data integrity issues. Because these operations correct formatting, structure, or obvious errors without using statistical properties of the target variable, they are safely applied to the entire dataset:

Step 4: Data Splitting (Train / Validation / Test)
Dividing the dataset into separate subsets. A common high-level split is 80% for training and 20% for testing. However, to support the model development loop in Step 6, we further split the training portion to carve out a validation set (or use cross‑validation techniques).

Step 5: Preprocessing Pipeline 2 – Advanced (Strictly Train-Only)
Any operation that learns statistical properties from the data must be performed here, after the split:

Step 6: Model Development Loop
Using the validation set (derived from the training split in Step 4) to iteratively improve the model without ever peeking at the final test set:

Step 7: Final Model Training (Full Train Set)
After finding the best hyperparameters through the development loop, train the final model using the entire training set (including any validation data) with those optimal parameters.

Step 8: Test Set Evaluation
The test set, which has been completely untouched throughout the entire development process, is now used for the final evaluation. This provides the true estimate of how well the model will generalize to new, unseen data.

Step 9: Production Deployment & Monitoring
Deploying the model to a production environment where it can make predictions on real-world data, while continuously monitoring its performance and watching for drift or degradation over time.

ML Project Lifecycle Step 1: Raw Data Collection Step 2: Initial Dataset Creation (Rows × Columns) Step 3: Preprocessing Pipeline 1 — Data Cleaning Imputation, Encoding, Outliers, Derived Features Step 4: Data Splitting (Train + Test) Test Set HELD OUT Step 5: Preprocessing Pipeline 2 — Advanced Scaling, PCA, Feature Selection (Train Only!) Step 6: Model Development Loop Hyperparam Search → Train → Validate → Repeat Iterate & Tune Step 7: Final Model Training (Full Train Set) Step 8: Test Set Evaluation UNTOUCHED Data! Step 9: Production Deployment & Monitoring 1 2 3 4 5 6 7 8 9

The separation between the two preprocessing stages and the train/test split is particularly important. Basic data cleaning is performed before the split, while operations that learn parameters from the data, such as scaling and PCA, are handled after the split.

⚠ Critical: Data Leakage Prevention

2.7 Course Roadmap at a Glance

The topics in this course are organized around the main types of machine learning problems and the techniques used to solve them. We begin with classification and related concepts, then move to regression, clustering, dimensionality reduction, and neural networks. The roadmap shows where these topics appear during the course and how they relate to the broader machine learning workflow.

Category Topics Weeks
Classification k-NN, Decision Trees, Naïve Bayes, Logistic Regression, Random Forest, AdaBoost, Stacking 2, 5–7, 11
Regression OLS, Lasso/Ridge/Elastic Net, Regression Tree, kNN Regressor, Gradient Boosting 8–10
Clustering Agglomerative, K-Means, DBSCAN 12–14
Dimensionality Reduction PCA, Filter/Wrapper Feature Selection, RFE, Step-wise, Autoencoders 2–3, 9, 12
Neural Networks ANN with Backpropagation 11–12

3. Interactive Examples

Example 1: Classification vs. Regression Identifier

For each scenario below, classify whether it is a Classification or Regression problem. Click the button to reveal the answer.

Scenario A: An e-commerce platform wants to predict the exact dollar amount a visitor will spend on their next visit.

Regression. The output is a continuous numerical value ($0.00 – $∞).

Scenario B: A bank wants to flag credit card transactions as genuine or fraudulent.

Binary Classification. Two discrete classes: genuine / fraudulent.

Scenario C: A streaming service wants to predict the viewer rating (1–5 stars) for a new show. Hint: Is 4.2 a valid prediction?

Regression. Although we think of ratings as integers (1–5), the predicted value can be any real number in that range (e.g., 4.2), making it a continuous-output problem.

Example 2: Project Lifecycle Ordering Quiz

Using the dropdowns, place the 9 lifecycle steps in the correct order. Then click Check Order to see how you did.

Lifecycle Ordering Challenge

Step 1:

Step 4:

Step 5:   (Applied to which dataset only?)

Step 8:

4. Numerical Solutions

Problem 1: Classifying Problem Types

For each of the following five tasks, determine (i) the ML paradigm (Supervised / Unsupervised / Reinforcement), and (ii) the sub-type (Classification / Regression / Clustering / N/A).

Problem Statements (click to see all 5)
  1. Netflix groups users into 4 behavioral segments for targeted marketing.
  2. An astronomer trains a model to label telescope images as "star", "galaxy", "nebula", or "asteroid" using a labeled catalog.
  3. A farmer trains a model that predicts bushels of wheat per acre from rainfall, temperature, and soil readings.
  4. A self-driving car learns to navigate a simulation by receiving +10 points for reaching the destination and −1 for each collision.
  5. An HR system predicts whether a job candidate will accept or decline a job offer based on historical data.
📘 Step-by-Step Solution (click to reveal)
#ScenarioParadigmSub-typeReasoning
1Netflix user segmentationUnsupervisedClustering No pre-existing segment labels; discovering natural groups
2Astronomical image labelingSupervisedClassification Uses a labeled catalog with 4 discrete classes
3Wheat yield predictionSupervisedRegression Predicts continuous bushels-per-acre value
4Self-driving simulationReinforcementN/A Agent learns via reward signals from environment (not from labeled data)
5Job-offer acceptance predictionSupervisedClassification Binary outcome (accept/decline) trained on historical labeled records

Problem 2: The Mitchell Framework (T, E, P)

A hospital is building a model to readmit or not readmit patients within 30 days of discharge. It uses 50,000 historical records with known readmission outcomes. The model is judged on its overall percentage of correct predictions on a held-out validation set.

📘 Identify T, E, P — Step-by-Step

Step 1: Identify the Task (T).

The model must make a binary decision for each patient: Classify whether the patient will be readmitted within 30 days or not.


Step 2: Identify the Experience (E).

The training corpus: 50,000 historical patient records with known readmission outcomes (labels).


Step 3: Identify the Performance measure (P).

Accuracy = \( \frac{\text{# correct predictions}}{\text{# total predictions}} \) on a held-out validation set, expressed as a percentage.


Sanity check: As the model studies more labeled records (E increases), its accuracy (P) on the classification task (T) should improve. ✓

Problem 3: Train / Test Splitting Check

A dataset has 2,500 labeled samples. We use an 80/20 train/test split.

📘 Step-by-Step Calculations

Step 1: Compute training-set size.

\( |\text{Train}| = 0.80 \times 2500 = \mathbf{2000} \) samples

Step 2: Compute test-set size.

\( |\text{Test}| = 0.20 \times 2500 = \mathbf{500} \) samples

Step 3: Key rule — which set should be used for each purpose?

  • ✅ Training set (2,000): Model training, cross-validation, hyperparameter tuning, and fitting any preprocessing (scaling, PCA).
  • ✅ Test set (500): Used only once at the very end for final model evaluation. Preprocessing parameters learned on the training set are applied to it.

5. Try It Yourself

Problem 1 — Paradigm & Sub-type Identification

For each scenario, write down your answers (Paradigm + Sub-type + 1-sentence reasoning) and then check against the solution.

  1. An insurance company predicts the repair cost ($) of a car accident from accident details and photos.
  2. Spotify automatically creates 6 music "mood" playlists from a large unlabeled song library.
  3. An anti-virus flags downloaded files as safe or malware using a database of 2 million previously labeled files.
  1. Supervised · Regression — predicts continuous dollar cost from labeled historical repair records.
  2. Unsupervised · Clustering — discovers 6 natural mood groupings in unlabeled audio features.
  3. Supervised · (Binary) Classification — predicts one of two discrete classes using 2M labeled training examples.
Problem 2 — Train/Test Splits

A dataset has 8,400 labeled samples and uses a 75/25 train/test split.

  1. How many samples go to the training set?
  2. How many samples go to the test set?
  3. Name two operations that should be learned only on the training set and then applied to the test set.
  1. \( 0.75 \times 8400 = \mathbf{6,300} \) training samples
  2. \( 0.25 \times 8400 = \mathbf{2,100} \) test samples
  3. Any two of: feature scaling (standardization / normalization), PCA transformation, feature selection mask, imputation statistics (mean/median/mode).
Problem 3 — Mitchell's T/E/P Framework

A rideshare company builds a model to predict passenger cancellation (Yes / No) for a booked ride. It has 120,000 past bookings with cancellation labels. Performance is measured as the fraction of rides whose cancellation outcome is correctly predicted.

Identify T (Task), E (Experience), and P (Performance measure).

  • T: Binary classification — for each booked ride, predict whether the passenger will cancel or not.
  • E: Dataset of 120,000 past bookings with known cancellation labels.
  • P: Classification Accuracy = \( \frac{\text{Correctly predicted cancellations/non-cancellations}}{\text{Total bookings}} \).

6. Interactive Quiz

Answer all 5 MCQs. Click on an option to get instant feedback.

Your score: 0 / 5

7. Key Takeaways

  1. ML = Learning from experience (data), not explicit programming. The Mitchell framework (T, E, P) formally characterizes every ML problem.
  2. 3 paradigms: Supervised (labeled data), Unsupervised (pattern discovery), Reinforcement (reward-driven agents). This course focuses on the first two.
  3. Supervised splits: Classification → discrete classes; Regression → continuous numerical values. The output type determines which one you have.
  4. Curse of dimensionality: High-dimensional data breaks models. Use dimensionality reduction (feature selection / extraction) wisely.
  5. Lifecycle discipline = success: Follow the 9-step lifecycle. Never fit preprocessing on the full dataset before splitting — that is data leakage.
  6. Test set = gold standard: The held-out test set is evaluated once, at the very end, to estimate true generalization performance.

8. Common Pitfalls

  1. Confusing classification and regression by task topic alone. A "prediction" about rating or house price is regression (continuous), not classification. Always ask: what is the output type?
  2. Data leakage via preprocessing. StandardScaler / PCA fitted on the entire dataset (before train/test split) leaks test-distribution information. Fix: fit on train, apply to both train and test.
  3. Peeking at the test set. Tuning hyperparameters based on repeated test-set evaluations turns the test set into a de-facto validation set, inflating scores. Use cross-validation on the training set instead.
  4. Assuming "more features = better performance." Irrelevant features introduce noise and hurt generalization (curse of dimensionality). Dimensionality reduction is a feature, not an afterthought.
  5. Skipping the data cleaning step. Missing values, outliers, and mis-encoded categories silently destroy downstream model quality.
  6. Calling every grouping task "clustering." If the groups are predefined (e.g., "assign each patient to one of 4 pre-labeled disease types"), that's classification. Only use clustering when labels do not exist.

9. Resources